const WebSocket=require("ws")
const wss=new WebSocket.Server({port:8080})
let clientList=[]
wss.on("connection",function(client){
     console.log("connection")
   clientList.push(client)
   client.on("message",function(message){
      console.log(message)
      broadcast(message)
   })
   client.on("close",function(){
      console.log("close")
   })
})
function broadcast(message){
    for(let client of clientList){
        client.send(message)
    }
}